import { Core } from './core/core';
import Shape from './core/core.shape';
import {Group} from './core/core.group';

interface ICanvasCfg extends Core.IConfig{
  width: number;
  height: number;
  widthCanvas: number;
  heightCanvas: number;
  pixelRatio: number;
  containerDOM: HTMLCanvasElement;
  context: CanvasRenderingContext2D;
}

export default class Canvas extends Group {

  props: ICanvasCfg;

  constructor(config: ICanvasCfg ) {
    super();
    this.props = config;
    this.props.context = this.props.containerDOM.getContext('2d');
  }

  clear() {

  }

  draw(){
    this.children.forEach(item=>{
      item.setContext(this.getProps('context'));
      item.drawInner();
    });
  }
}